/**
 * Copyright (c) 2012, lincomb Technology CO,LDT. All rights reserved.
 * Module: App推送
 * File: GeTuiDao.java
 * Purpose: 查询App推送消息Dao层
 * Date: 2016-6-6
 */
package com.edais.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.edais.persistence.GeTuiMapper;

/**
 * ClassName: GeTuiDao 
 * @Description: App推送消息Dao类
 * @author ZuoJun
 * @date 2016-6-6 17:36:29
 */
@Repository

public class GeTuiDao {
	
	@Autowired
	private GeTuiMapper geTuiMapper;
	/**
	 * 保存手机设备信息
	 * @param params
	 */
	public void saveMobileInfo(Map<String, String> params){
		geTuiMapper.saveMobileInfo(params);
	}
	
	/**
	 * 更新手机设备信息
	 * @param params
	 */
	public void updateMobileInfo(Map<String, String> params){
		geTuiMapper.updateMobileInfo(params);
	}
			
	/**
	 * 根据设备编号查询userId
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryUserIdByDeviceNum(Map<String, String> params){
		return geTuiMapper.queryUserIdByDeviceNum(params);
	}
	
	/**
	 * @Description: 根据用户ID、消息类别查询消息或公告信息
	 * @param params
	 * @return List<Map<String, Object>>
	 * @author ZuoJun
	 * @date 2016-6-6 17:36:39
	 */
	public List<Map<String, Object>> queryMessageByType(Map<String, Object> params){
		
		List<Map<String, Object>> messageList = geTuiMapper.queryMessageByType(params);
		
		List<Map<String, Object>> rtnList = new ArrayList<Map<String,Object>>();
		
		for(int i = 0; i < messageList.size(); i++){
			
			Map<String, Object> map = messageList.get(i);
			
			Map<String, Object> buildMap = new HashMap<String, Object>();
			
			buildMap.put("title", map.get("TITLE"));
			buildMap.put("details", map.get("PUSH_DETAILS"));
			buildMap.put("time", map.get("SEND_TIME"));
			
			rtnList.add(buildMap);
			
		}
		
		return rtnList;
	}
	
	/**
	 * @Description: 根据用户ID、消息类别查询消息或公告信息条数
	 * @param params
	 * @return int
	 * @author ZuoJun
	 * @date 2016-6-7 11:34:39
	 */
	public int queryMessageCountByType(Map<String, Object> params){
		
		return geTuiMapper.queryMessageCountByType(params);
	}
	

	
	/**
	 * @Description: 查询媒体报道信息
	 * @param params
	 * @return List
	 * @author ZuoJun
	 * @date 2016-6-12 11:10:39
	 */
	public List<Map<String, Object>> queryMediaReportByType(Map<String, Object> params){
		
		List<Map<String, Object>> messageList = geTuiMapper.queryMediaReportByType(params);
		
		List<Map<String, Object>> rtnList = new ArrayList<Map<String,Object>>();
		
		for(int i = 0; i < messageList.size(); i++){
			
			Map<String, Object> map = messageList.get(i);
			
			Map<String, Object> buildMap = new HashMap<String, Object>();
			buildMap.put("id", map.get("id"));
			buildMap.put("title", map.get("title"));
			buildMap.put("details", map.get("html_url"));
			buildMap.put("imageUrl", map.get("small_icon_url"));
			buildMap.put("content", map.get("affiche_content"));
			buildMap.put("time", map.get("create_time"));
			
			rtnList.add(buildMap);
			
		}
		return rtnList;
	}
	
	/**
	 * @Description: 查询媒体报道信息条数
	 * @param params
	 * @return int
	 * @author ZuoJun
	 * @date 2016-6-12 11:11:39
	 */
	public int queryMediaReportCountByType(Map<String, Object> params){
		
		return geTuiMapper.queryMediaReportCountByType(params);
	}
	
	
	/**
	 * 查询媒体报道详细信息
	 * @param params
	 * @return
	 */
	public Map<String, Object> queryMediaReportDetail(Map<String, Object> params){
		Map<String, Object> map = geTuiMapper.queryMediaReportDetail(params);
		Map<String, Object> buildMap =null;
		if(null!=map){
			buildMap= new HashMap<String, Object>();
			buildMap.put("title", map.get("title"));
			buildMap.put("details", map.get("html_url"));
			buildMap.put("imageUrl", map.get("small_icon_url"));
			buildMap.put("content", map.get("affiche_content"));
			buildMap.put("time", map.get("create_time"));
		}
		return buildMap;
	}
	
	/**
	 * @Description: 根据用户ID查询未读信息数
	 * @param params
	 * @return List
	 * @author WuHan
	 * @date 2016-6-7 21:10:00
	 */
	public List<Map<String,Object>> queryUnReadNumList(Map<String, Object> params){
		
		return geTuiMapper.queryUnReadNumList(params);
		
	}
	
	/**
	 * @Description: 清除用户未读信息数
	 * @param params
	 * @author WuHan
	 * @date 2016-6-7 21:18:00
	 */
	public void clearUnReadNum(Map<String, Object> params){
		
		 geTuiMapper.clearUnReadNum(params);
		
	}
	
}
